#include <iostream>
using namespace std;

#define forn(i,n) for(int i=0;i<n;i++)
#define forsn(i,s,n) for(int i=s;i<n;i++)

int n, l;
int cuts[52];
int M[52][52];

int cortar(int x0, int x1){
	if( M[x0][x1] > 0 ) return M[x0][x1];
	if(x0+1==x1) return 0;

	int res = cuts[x1] - cuts[x0];

	if(x0+2<x1){
		int min = -1;
		int costo;
		forsn(i,x0+1,x1){
			costo = cortar(x0,i) + cortar(i,x1);
			if( costo < min || min < 0 ) min = costo;
		}
		res += min;
	}
	M[x0][x1] = res;
	return res;
}

int main(){
	while( cin >> l && l!=0 ){
		cin >> n;

		cuts[0]=0;
		forn(i,n) cin >> cuts[i+1];
		cuts[n+1]=l;

		forn(x,n+2) forn(y,n+2) M[x][y]=0;
		cout << "The minimum cutting is " << cortar(0,n+1) << "." << endl;
	}
	return 0;
} 
